// page/trip/trip.js
const api = require('../../utils/api.js');

Page({
    data: {
		trip: null,
        options: null
    },
    onReady: function() {
        let self = this;
        wx.setNavigationBarTitle({
            title: self.data.options.name
        })
    },
    onLoad: function(options) {
		let self = this;
		let id = options.id;
		self.setData({
			options
		});
		wx.showToast({
			title: '正在加载',
			icon: 'loading',
			duration: 10000,
			mask: true
		});
		api.trip.waypoint(id,(state,res) => {
			if(state === 'success'){
				let trip = res.data;
				// console.log(trip);
				self.setData({
					trip
				});
				wx.hideToast();
			}
		})
    },
	goUser: function(e){
		let dataUser = e.currentTarget.dataset;
		wx.navigateTo({
			url: `../user/user?id=${dataUser.id}`
		})
	},
	goWaypoint: function(e){
		let dataWyp = e.currentTarget.dataset;
		wx.navigateTo({
			url: `../waypoint/waypoint?tripId=${dataWyp.tripid}&waypointId=${dataWyp.wayid}`,
		})
	}
})